﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Timers;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;

namespace WebApplication1
{
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            System.Timers.Timer myTimer = new System.Timers.Timer(1000);
            //TaskAction.SetContent 表示要调用的方法
            myTimer.Elapsed += new System.Timers.ElapsedEventHandler(TaskAction.SetContent);
            myTimer.Enabled = true;
            myTimer.AutoReset = true;
        }
    }

    internal class TaskAction
    {
        internal static void SetContent(object sender, ElapsedEventArgs e)
        {
            if(DateTime.Now.ToString("HH:mm:ss")=="16:45:00")
            {
                Console.WriteLine(DateTime.Now);
            }    
        }
    }
}
